using UnityEngine;

public class Crosshair : MonoBehaviour
{
	private FPSController fpsController;

	public Sprite CrosshairImg;

	public Sprite CrosshairZoomImg;

	public Sprite CrosshairHit;

	public float HitDuration = 0.2f;

	private float timeTemp;

	private void Start()
	{
		if ((bool)base.transform.root)
		{
			fpsController = base.transform.root.GetComponent<FPSController>();
		}
		else
		{
			fpsController = base.transform.GetComponent<FPSController>();
		}
	}

	public void Hit()
	{
		timeTemp = Time.time;
	}

	private void Update()
	{
	}

	private void OnGUI()
	{
		if (!fpsController || !fpsController.character || !fpsController.character.IsMine)
		{
			return;
		}
		if ((bool)CrosshairImg)
		{
			UnitZ.Hud.Crosshair.sprite = CrosshairImg;
			UnitZ.Hud.Crosshair.gameObject.SetActive(value: true);
		}
		else
		{
			UnitZ.Hud.Crosshair.gameObject.SetActive(value: false);
		}
		if ((bool)CrosshairZoomImg)
		{
			UnitZ.Hud.CrosshairScope.sprite = CrosshairZoomImg;
			UnitZ.Hud.CrosshairScope.gameObject.SetActive(fpsController.zooming);
			if ((bool)CrosshairImg)
			{
				UnitZ.Hud.Crosshair.gameObject.SetActive(!fpsController.zooming);
			}
		}
		else
		{
			UnitZ.Hud.CrosshairScope.gameObject.SetActive(value: false);
		}
		if (Time.time < timeTemp + HitDuration)
		{
			UnitZ.Hud.CrosshairHit.gameObject.SetActive(value: true);
			UnitZ.Hud.CrosshairHit.sprite = CrosshairHit;
		}
		else
		{
			UnitZ.Hud.CrosshairHit.gameObject.SetActive(value: false);
		}
	}
}
